-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Store source file in TASTY attributes #18948
Store source file in TASTY attributes #18948
Conversation
979699d
to
a7e774a
Compare
34629c2
to
028219c
Compare
6a8eaff
to
5268c6f
Compare
We generalize the internal encoding of `Attributes` to be a list of tags. Then we add add helper methods to have simpler ways to interact with this abstraction using booleans. This implies that the pickling/unpickling can be agnostic of the semantics of each tag. Therefore reducing the number of places that need to be updated when we add a new tag. Useful for #19074, #19033, and #18948.
We generalize the internal encoding of `Attributes` to be a list of tags. Then we add add helper methods to have simpler ways to interact with this abstraction using booleans. This implies that the pickling/unpickling can be agnostic of the semantics of each tag. Therefore reducing the number of places that need to be updated when we add a new tag. Useful for scala#19074, scala#19033, and scala#18948.
27881d3
to
8f71739
Compare
We add a `Utf8` encoding to the grammar. This should not to be confused with the `UTF8` name tag. This mistake was made in the `Comment` format. We also add corresponding `writeUtf8` and `readUtf8` methods to the `TastyBuffer`. This is also useful for #18948
9e01840
to
50a8ca6
Compare
``` | ||
|
||
Standard Section: "Attributes" Attribute* | ||
```none | ||
Attribute = SCALA2STANDARDLIBRARYattr | ||
EXPLICITNULLSattr | ||
SOURCEFILEattr Utf8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be raw utf8 or a nametable reference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
30ad31e
to
adf7e3f
Compare
cad4d30
to
b52d156
Compare
b52d156
to
791c6fd
Compare
else if isStringAttrTag(tag) then | ||
val utf8Ref = readNameRef() | ||
val value = nameAtRef(utf8Ref).toString | ||
stringTagValue += tag -> value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps we should still validate the tags - there's a (hopefully unlikely) possibility of someone stuffing the attribute section with duplicates/invalid tags in the correct range
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invalid tags are checked with isStringAttrTag
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I should add to the spec the fact that attribute tags cannot be repeated. I could also specify that they must be in order to make it reproducible.
This introduces the first non-boolean attribute to the TASTY format. We Split the tags into a set of boolean tags and string tags to handle This new kind of attribute. We keep some tags as unknown to allow for additional kinds of tags in the future.
Also refactor accesses to the tasty attributes to get them directly from the compilation unit info instead of the unpickler.
The only missing step is in the TODO added in this commit.
0631d67
to
e942cd0
Compare
Add source file to TASTy attributes. This is a first step towards removing the
@SourceFile
annotation.Release notes
Tools that read TASTy need to know that the source file must be unpickled from TASTy attributes.